import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AppUserVO, AppUserForm, AppUserQuery } from '@/api/system/appUser/types';

/**
 * 查询应用用户列表
 * @param query
 * @returns {*}
 */

export const listAppUser = (query?: AppUserQuery): AxiosPromise<AppUserVO[]> => {
  return request({
    url: '/system/appUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询应用用户详细
 * @param userId
 */
export const getAppUser = (userId: string | number): AxiosPromise<AppUserVO> => {
  return request({
    url: '/system/appUser/' + userId,
    method: 'get'
  });
};

/**
 * 新增应用用户
 * @param data
 */
export const addAppUser = (data: AppUserForm) => {
  return request({
    url: '/system/appUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用用户
 * @param data
 */
export const updateAppUser = (data: AppUserForm) => {
  return request({
    url: '/system/appUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用用户
 * @param userId
 */
export const delAppUser = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/system/appUser/' + userId,
    method: 'delete'
  });
};
